/*
 * Name: Joon Ho Cho
 * Date: 10/24/2008
 * Course: 15-437
 */
package scheduler.controller;



import javax.servlet.http.HttpServletRequest;



import org.mybeans.dao.DAOException;
import org.mybeans.forms.FormBeanFactory;

import scheduler.formbean.EditSectionForm;

import scheduler.model.Model;
import scheduler.model.ScheduleDao;



public class EditAction extends Action {
	private FormBeanFactory<EditSectionForm> formBeanFactory = FormBeanFactory.getInstance(EditSectionForm.class,"<>\"");

	private ScheduleDao scheduleDao;
	

    public EditAction(Model model) {
    	scheduleDao = model.getScheduleDao();
  
	}

    public String getName() { return "edit.do"; }

    public String perform(HttpServletRequest request) {
    	EditSectionForm form = formBeanFactory.create(request);
    	
    	
    	
    	try {
			scheduleDao.changeSection(form.getId(), form.getSection());
		} catch (DAOException e1) {
			// TODO Auto-generated catch block
			System.out.println("SECTIOB NOT CHANGED");
			e1.printStackTrace();
		}
       
		 return "schedule.do";
    }
}
